export default {
  // cartList(state) {
  //   return state.cartList;
  // },
  // 计算产品的总数量
  cartListProNum(state) {
    let count = state.cartList.reduce((total, item) => {
      return total + item.count;
    }, 0);
    return count;
  },
  // 计算选中商品的总价
  cartCount(state) {
    const cartListTrue = state.cartList.filter((item) => {
      return item.checked;
    });
    return cartListTrue.reduce((total, item) => {
      return total + item.count * parseFloat(item.newPrice.replace(/[^0-9\.]/ig, ""));
    }, 0).toFixed(2)
  }
}
